import com.bird { Interface }
import com.bird.service {Service}
import com.bird.intent { Intent }
import ceylon.collection { HashMap, MutableMap }
import com.bird.bundle { Bundle }
import java.lang {Thread, Runnable}

class ExecutionThread(Service service) extends Thread() {
	
	shared actual void run() {
		service.onCreate(Bundle());
	}
	
}

shared class ServiceManager() {
	
	variable MutableMap<Object, Service> _serviceMap := HashMap<Object, Service>();
			
	shared void putService(Entry<Object, Service> entry) {
		this._serviceMap.put(entry.key, entry.item);
	}
	
	shared void start() {
						
		for (entry in _serviceMap) {
			print("Initializing Thread for service " className(entry.item) "");
			ExecutionThread(entry.item).start();			
		}
	}
					
	shared Interface executeIntent(Intent intent) {
		throw Exception();
	}
}